package com.example.onlinemarket.util;

import android.content.Context;
import android.content.DialogInterface;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;

import com.example.onlinemarket.fragment.UserFragment;
import com.example.onlinemarket.graphics.UserInfoDialog;

import static com.example.onlinemarket.Application.loginUser;

public class DialogUtil {
    public static AlertDialog getDialog(Context context, String title, String msg, DialogInterface.OnClickListener onClickListener){
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(title);
        builder.setMessage(msg);
        builder.setCancelable(true);
        builder.setPositiveButton("确定", onClickListener);
        builder.setNegativeButton("取消", (dialog, which) -> {});
        return builder.create();
    }

    public static AlertDialog getUpdateEmailDialog(@NonNull Context context, UserFragment.RefreshListener listener){
        return UserInfoDialog.newInstance(context, "修改邮箱地址", "邮箱：", loginUser.getEmail(), listener);
    }

    public static AlertDialog getUpdateAddressDialog(@NonNull Context context, UserFragment.RefreshListener listener){
        return UserInfoDialog.newInstance(context, "修改收货地址", "收货地址：", loginUser.getAddress(), listener);
    }
}
